package com.empty.oredermenu.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.empty.oredermenu.R
import com.empty.oredermenu.javabeen.MenuListAdapterBeen
import com.empty.oredermenu.utils.GlideRoundTransform
import com.empty.oredermenu.utils.UrlAllUtils

/**
 * Created by empty cup on 2017/7/17.
 */
class MenuDetaliLiatAdapter(val context :Context,val listbeen :ArrayList<MenuListAdapterBeen>) :BaseAdapter(){
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var contView = convertView;
        var viewHolder :ViewHolder
        if (contView == null){
            contView = LayoutInflater.from(context).inflate(R.layout.adapter_menudetaillist,null)
            viewHolder = ViewHolder()
            viewHolder.menu_title = contView.findViewById(R.id.menu_title) as TextView
            viewHolder.image_menu = contView.findViewById(R.id.image_menu) as ImageView
            contView.setTag(viewHolder);
        }else{
            viewHolder = contView.getTag() as ViewHolder
        }
        //图片圆角处理
        Glide.with(context).
                load(UrlAllUtils.URL_IMAGE+listbeen.get(position).img)
                .asBitmap()
//                .transform(GlideRoundTransform(context,10))
                .placeholder(R.mipmap.mvr)
                .into(viewHolder.image_menu)

        viewHolder.menu_title!!.text = listbeen.get(position).name
        return contView!!
    }

    override fun getItem(position: Int): Any {
        return null!!
    }

    override fun getItemId(position: Int): Long {
        return 0
    }

    override fun getCount(): Int {
        return listbeen.size
    }
    class ViewHolder{
        var image_menu : ImageView? = null
        var menu_title :TextView? = null
    }

}
